<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // This will read file and send information to other function
  function getData (txt,callback) {
    let xmlhttp;

    if (window.XMLHttpRequest) {
      xmlhttp = new XMLHttpRequest();
    } else {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {
      if (xmlhttp.readyState == 4) {
        let lines = xmlhttp.responseText;
        callback(intoArray(lines));
      }
    }

    xmlhttp.open("GET", txt, true);
    xmlhttp.send();
  }

  function intoArray (lines) {
    let lineArr = lines.split('\r\n');

    // Just to check if it works output lineArr[index] as bellow*

    return lineArr;
  }

  getData('text.txt',(arr) => {
    let arr1 = arr;
    getData('text2.txt',(arr) => {
      let arr2 = arr;
      let total = 0;
      for(item of arr1){
        if (arr2.indexOf(item) !== -1) {
          total++;
          console.log(item+"包含 共"+ total);
        } else {
          console.log(item  +"不包含");
        }
      }
    
    });
  });


</script>

</html>